package com.jucai.pppeiyouclient.weidget.photo;

import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.jucai.pppeiyouclient.R;

import java.util.List;


public class AllPictureDirPopupWindow extends AllPictureBasePopupWindow<AllPictureImageInfo> {
    private ListView mListDir;

    public AllPictureDirPopupWindow(int width, int height, List<AllPictureImageInfo> datas, View convertView) {
        super(convertView, width, height, true, datas);
    }

    @Override
    public void initViews() {
        mListDir = (ListView) findViewById(R.id.id_list_dir);
        mListDir.setAdapter(new AllPictureCommonAdapter<AllPictureImageInfo>(context, mDatas, R.layout.all_picture_item_listdir) {
            @Override
            public void convert(AllPictureViewHolder helper, AllPictureImageInfo item, int position) {
                helper.setText(R.id.id_dir_item_name, item.getName());
                helper.setImageByUrl(R.id.id_dir_item_image, item.getFirstImagePath());
                helper.setText(R.id.id_dir_item_count, item.getCount() + "张");
            }
        });
    }

    public interface OnImageDirSelected {
        void selected(AllPictureImageInfo floder);
    }

    private OnImageDirSelected mImageDirSelected;

    public void setOnImageDirSelected(OnImageDirSelected mImageDirSelected) {
        this.mImageDirSelected = mImageDirSelected;
    }

    @Override
    public void initEvents() {
        mListDir.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                if (mImageDirSelected != null) {
                    mImageDirSelected.selected(mDatas.get(position));
                }
            }
        });
    }

    @Override
    public void init() {

    }

    @Override
    protected void beforeInitWeNeedSomeParams(Object... params) {

    }

}
